package controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pojo.Patient;
import pojo.Result;
import service.PatientService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@Api(tags = "患者管理接口")
@RestController
@RequestMapping("/patient")
@CrossOrigin(origins = "*")
public class PatientController {
    @Autowired
    private PatientService patientService;

    /**
     * 添加患者信息
     * @param patient 患者信息
     * @return 操作结果
     */
    @ApiOperation(value = "添加患者信息", notes = "添加新的患者信息")
    @PostMapping("/add")
    public Result addPatient(@ApiParam(value = "患者信息", required = true) @RequestBody Patient patient) {
        return patientService.addPatient(patient);
    }

    /**
     * 获取患者列表
     * @param userId 用户ID
     * @return 患者列表
     */
    @ApiOperation(value = "获取患者列表", notes = "根据用户ID获取患者列表")
    @GetMapping("/list")
    public Result getPatientList(@ApiParam(value = "用户ID", required = true) @RequestParam Integer userId) {
        return patientService.getPatientList(userId);
    }

    /**
     * 获取患者详情
     * @param patientId 患者ID
     * @return 患者详情
     */
    @ApiOperation(value = "获取患者详情", notes = "根据患者ID获取患者详细信息")
    @GetMapping("/detail/{patientId}")
    public Result getPatientDetail(@ApiParam(value = "患者ID", required = true) @PathVariable Integer patientId) {
        return patientService.getPatientDetail(patientId);
    }
} 